<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

function get_user_profile($field = NULL) {
    $CI = & get_instance();

    $CI->db->where('user_id',  $CI->session->userdata('user_id'));
    $query = $CI->db->get('auth_user_profiles');

    if(is_null($field)) {
        return $query->row();
    }
    else
        return $query->row($field);
}

function get_user_id() {
    $query = get_user_profile('user_id');
    return $query;
}

function get_team_id() {
    $query = get_user_profile('team_id');
    return $query;
}

function userNotLogged() {

    $CI = & get_instance();
    $CI->session->set_flashdata('message', lang('message_notlogged'));
    redirect('auth/login');
}

function is_logged_in () {
    $CI = & get_instance();
    return $CI->session->userdata('status');
}

function is_admin () {
    $CI = & get_instance();
    if($CI->session->userdata('role') == 'admin')
        return TRUE;
    else
        return FALSE;
}